package com.txx.myspringboot.initializer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;

import java.util.HashMap;
import java.util.Map;

/**
 * @创建人 tuxx
 * @创建时间 2020/5/8
 * @描述
 */
@Order(3)
@Slf4j
public class ThridInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
    @Override
    public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
        ConfigurableEnvironment environment = configurableApplicationContext.getEnvironment();
        Map<String,Object> map = new HashMap<>();
        map.put("thridKey","thridValue");
        MapPropertySource mapPropertySource = new MapPropertySource("thridInitializer",map);
        environment.getPropertySources().addLast(mapPropertySource);
        log.info("txx's thridInitializer is run");
    }
}
